package com.object.module.cbb.frontEnd;

import com.object.configuration.utils.PageUtils;
import com.object.configuration.utils.Q;
import com.object.module.cbb.entity.CbbOrderEntity;
import com.object.module.cbb.service.CbbOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


/**
 * 订单
 *
 * @author 小🌤
 * @email 1578442339@qq.com
 * @date 2021-12-29 21:06:27
 */
@RestController
@RequestMapping("/frontend/order")
public class FrontEndCbbOrderController {
    @Autowired
    private CbbOrderService cbbOrderService;


    @GetMapping("/userId/{userId}")
    public Q phone(@PathVariable("userId") Long userId, String status
            , String key) {
        List<CbbOrderEntity> list = cbbOrderService.allPhone(userId, status, key);
        return Q.ok().put("list", list);
    }

    @GetMapping("/phone")
    public Q phone(@RequestParam Map<String, Object> params) {
        PageUtils page = cbbOrderService.queryPagePhone(params);
        return Q.ok().put("page", page);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{orUuid}")
    public Q info(@PathVariable("orUuid") String orUuid) {
        CbbOrderEntity cbbOrder = cbbOrderService.getById(orUuid);
        return Q.ok().put("cbbOrder", cbbOrder);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public Q save(@RequestBody CbbOrderEntity cbbOrder) {
        cbbOrderService.saveOrder(cbbOrder);
        return Q.ok();
    }

    /**
     * 保存
     */
    @RequestMapping("/save/saveOrder")
    public boolean saveOrder(@RequestBody CbbOrderEntity cbbOrder) {
      return  cbbOrderService.saveOrderPay(cbbOrder);
    }


}
